package com.musicserver.controller;

import com.musicserver.common.R;
import com.musicserver.model.request.RankListRequest;
import com.musicserver.service.RankListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class RankListController {
    @Autowired
    private RankListService rankListService;

    // 提交评分
    @PostMapping("/rankList/add")
    public R addRank(@RequestBody RankListRequest rankListAddRequest) {
        return rankListService.addRank(rankListAddRequest);
    }

    // 取指定歌单的评分(平均)
    @GetMapping("/rankList")
    public R rankOfSongListId(@RequestParam Long songListId) {
        return rankListService.rankOfSongListId(songListId);
    }

    @GetMapping("/rankList/user")
    public R rankOfUserId(@RequestParam Long consumerId,
                          @RequestParam Long songListId) {
        return rankListService.rankOfUserId(consumerId, songListId);
    }

}
